(in-package :wsml2reasoner)
;;;; $Id: example.lisp 2578 2007-09-22 10:30:28Z mev $

(defparameter *namespaces* (make-hash-table :test #'equal))

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter *etel-pathname* #P"eTel_CRM_and_Fulfillment_BPMO_20070803.wsml")
  (defparameter *bpmo-pathname* #P"20070529_BPMO-v1_1.wsml"))

(defun test-run (&optional (test "?x memberOf ?y"))
  (let ((question test))
    (multiple-value-bind (ontology expression-factory)
	(load-ontology-recursively *etel-pathname*)
      (ask ontology expression-factory question))))
	 
(defun print-results (results ontology)
  (let ((iterator (#"iterator" results)))
    (do ((pair (#"next" iterator) (#"next" iterator)))
	((not (#"hasNext" iterator)))
      (print-hash-map pair ontology))))
	       
(defun print-hash-map (hash-map ontology)
  (let ((iterator (#"iterator" (#"values" hash-map))))
    (do ((item (#"next" iterator) (#"next" iterator)))
	((not (#"hasNext" iterator)))
      (format t "~A~%" (term->string item ontology)))))

(defun term->string (term ontology) 
  ((let (vistor (new 'VisitorSerializeWSMLTerms ontology))
     (#"accept" term visitor)
     (#"getSerializedObject" visitor))))